BASEDIR=$(CURDIR)
INPUTDIR=$(BASEDIR)
OUTPUTDIR=$(BASEDIR)/output

SSH_HOST=saravia
SSH_PORT=51022
SSH_USER=freedom
SSH_TARGET_DIR=/home/saravia

help:

	@echo ' Makefile for a c-xperto web-site                     '
	@echo '                                                      '
	@echo ' Usage:                                               '
	@echo '    make publish          Upload to saravia...        '
	@echo '                                                      '

clear:
	echo "" > $(OUTPUTDIR)/style.css
	echo "" > $(OUTPUTDIR)/script.js

merge:
	for file in css/*.css ; do               \
	cat "$$file" >> $(OUTPUTDIR)/style.css ; \
	done

merge_js:
	for file in js/*.js ; do                 \
	cat "$$file" >> $(OUTPUTDIR)/script.js ; \
	done

spare_lines:
	tr -d '\n' < $(OUTPUTDIR)/script.js > /tmp/script.js
	cat /tmp/script.js > $(OUTPUTDIR)/script.js

spare_lines_js:
	tr -d '\n' < $(OUTPUTDIR)/style.css > /tmp/style.css
	cat /tmp/style.css > $(OUTPUTDIR)/style.css

compile: clear merge merge_js spare_lines spare_lines_js

publish: compile
	rsync -e "ssh -p $(SSH_PORT)" -P -rvzc --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)/

.PHONY: help clear merge spare_lines compile publish
